package com.hxy.travel.job;

import com.hxy.travel.constant.RedisConstant;
import com.hxy.travel.utils.QiniuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.JedisPool;

import java.util.Iterator;
import java.util.Set;

public class ClearImgJob {


    @Autowired
    private JedisPool jedisPool;


    public void clearImg(){
        Set<String> setImg = jedisPool.getResource().sdiff(RedisConstant.SETMEAL_PIC_RESOURCES, RedisConstant.SETMEAL_PIC_DB_RESOURCES);

        Iterator<String> iterator = setImg.iterator();

        while (iterator.hasNext()){
            String pic = iterator.next();

            System.out.println("名称"+pic);

            QiniuUtils.deleteFileName4Qiniu(pic);

            jedisPool.getResource().srem(RedisConstant.SETMEAL_PIC_RESOURCES,pic);
        }


    }
}
